﻿Shader "Hidden/NormalMixShader"
{
    Properties
    {
        _TexA ("Texture", 2D) = "white" {}
        _TexB ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "Queue"="Transparent" }
        LOD 100
        Cull Off ZWrite Off ZTest Always Fog{ Mode Off }

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };
            
            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = v.vertex;
                o.uv = v.uv;
                return o;
            }

            sampler2D _TexA;
            sampler2D _TexB;

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 colA = tex2D(_TexA, i.uv);
                fixed4 colB = tex2D(_TexB, i.uv);
                fixed4 col;
                col.rgb = colA.rgb * colA.a + colB.rgb * (1.0 - colA.a);
                col.a = colA.a + colB.a * (1.0 - colA.a);
                return col;
            }

            ENDCG
        }
    }
}
